﻿@using UCosmic.Www.Mvc.Areas.Identity.Models.Self
@model AffiliationForm
@{
    ViewBag.Title = "Edit affiliation info";
    Layout = MVC.Shared.Views.layout;
}
@section Styles {
    <style type="text/css">
        .ucosmic #employee_form textarea {
            max-width: 415px;
            min-height: 4em;
            max-height: 8em;
        }
    </style>
}
@section Scripts
{
    @if (Model.Establishment.IsInstitution)
    {
        <script type="text/javascript">
            $(function () {
                var answerName = '@Html.NameFor(m => m.EmployeeOrStudent)';
                $('input[name="' + answerName + '"]').change(function () {
                    var value = $(this).val();
                    switch (value) {
                        case 'EmployeeOnly':
                        case 'Both':
                            $('#employee_form').slideDown();
                            break;

                        case 'StudentOnly':
                        case 'Neither':
                            $('#employee_form').slideUp();
                            break;

                        default:
                            break;
                    }
                });
            });
        </script>
    }
    @if (!Model.Establishment.IsInstitution || (Model.IsClaimingEmployee && Model.IsAcknowledged))
    {
        <script type="text/javascript">
            $(function () {
                $('#employee_form').show();
            });
        </script>
    }
}
<div class="wrap-960">
    <h2 class="push-down">
        My <i>@Model.Establishment.OfficialName</i> Affiliation
    </h2>
    <div class="split-form pull-down">
        <div class="left">
            @using (Html.BeginForm(
            MVC.Identity.Self.ActionNames.EditAffiliation,
            MVC.Identity.Self.Name,
            new
            {
                area = MVC.Identity.Name,
                httpMethod = "POST"
            }
            ))
            {
                <fieldset>
                    <legend>Affiliation Info</legend>
                    @Html.EditorForModel()
                </fieldset>
            }
        </div>
        <div class="right">
            @if (Model.Establishment.IsInstitution)
            {
                <p>
                    Please answer the questionnaire on the left.
                </p>
                <p>
                    If you are a <b>@Model.Establishment.OfficialName</b> employee, you can indicate
                    whether you are an administrator, faculty member, or staff.
                </p>
                <p>
                    Employees may optionally indicate their job title(s), department(s), and/or colleges.
                </p>
                <p>
                    When you are finished, click the <b>Save Changes</b> button.
                </p>
            }
            else
            {
                <p>
                    Because this affiliation is not with an academic institution, UCosmic assumes you
                    are an employee of <b>@Model.Establishment.OfficialName</b>.
                </p>
                <p>
                    Please enter your job title(s) and / or department(s) in the box on the left and
                    click <b>Save Changes</b>.
                </p>
            }
        </div>
    </div>
</div>
